package com.wuchengdong.web.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * 通用的swagger配置类
 */
@Configuration
public class SwaggerConfig {

    //项目名称
    private static final String PROJECT_TITLE = "sever";
    //项目版本
    private static final String PROJECT_VERSION = "0.1";
    //项目描述
    private static final String PROJECT_DESC = "美容院预约管理系统";
    //controller包的路径
    private static final String BASE_PACKAGE = "com.wuchengdong.web.controller";

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage(BASE_PACKAGE))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title(PROJECT_TITLE)
                .version(PROJECT_VERSION)
                .description(PROJECT_DESC)
                .build();
    }
}
